package com.ict.common;

import java.io.FileInputStream;
import java.util.Properties;

public class FileConfigGet {
	public String url;
	public String user;
	public String passWord;
	public String fileName;
	public String fileRoad;
	public String tableName;
	public String taigetidName;
	public String longitudeName;
	public String latitudeName;
	public String utctimeName;
	public String eliTime;
	public String wkTime;
	public String ggRoad;
	public String chartRoad;
	public String newFsName;
	public String clearEliTime;

	private String FILEPATH;

	public String getGgRoad() {
		return ggRoad;
	}

	public String getChartRoad() {
		return chartRoad;
	}

	public String getNewFsName() {
		return newFsName;
	}

	public String getTableName() {
		return tableName;
	}

	public String getTaigetidName() {
		return taigetidName;
	}

	public String getLongitudeName() {
		return longitudeName;
	}

	public String getLatitudeName() {
		return latitudeName;
	}

	public String getUtctimeName() {
		return utctimeName;
	}

	public String getUrl() {
		return url;
	}
	
	public String getUser() {
		return user;
	}

	public String getPassWord() {
		return passWord;
	}

	public String getFileName() {
		return fileName;
	}

	public String getFileRoad() {
		return fileRoad;
	}
	
	public String getEliTime(){
		return eliTime;
	}

	public String getWkTime() {
		return wkTime;
	}

	public String getClearEliTime() {
		return clearEliTime;
	}

	public String getProFileRoad(){
		String fileProRoad=System.getProperty("user.dir");
		fileProRoad=fileProRoad+"\\config.properties";
		FILEPATH=this.getFileRoad()+"\\logs\\GreenGraph_DataClear.log";
		System.out.println(fileProRoad);
		return fileProRoad;
	}
	
	public FileConfigGet(){
		Properties prop =  new Properties();
//		String filePath=fileRoad+"\\config.properties";
		try {
			FileInputStream ins = new FileInputStream(getProFileRoad());
			prop.load(ins);

			url =prop.getProperty("jdbc.url");
			user = prop.getProperty("jdbc.username");
			passWord =prop.getProperty("jdbc.password");
			fileName =prop.getProperty("FsName");
			fileRoad=prop.getProperty("FsRoad");
			tableName=prop.getProperty("TableName");
			taigetidName=prop.getProperty("taigetidName");
			longitudeName=prop.getProperty("longitudeName");
			latitudeName=prop.getProperty("latitudeName");
			utctimeName=prop.getProperty("utctimeName");
			eliTime=prop.getProperty("EliTime");
			wkTime=prop.getProperty("wkTime");
			ggRoad=prop.getProperty("ggShipGps");
			chartRoad=prop.getProperty("chart");
			newFsName=prop.getProperty("newFsName");
			clearEliTime=prop.getProperty("clearEliTime");

			System.out.println(toString());

			close(ins);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println("get Config Info Failed:"+e);
			LogUtils.LogWriteAppend(FILEPATH,TimeUtils.getNowTime()+e);
//			e.printStackTrace();
		}   
	}

	private void close(FileInputStream ins){
		try{
			ins.close();
		}catch (Exception e){
			System.out.println("输入流关闭异常："+e);
			LogUtils.LogWriteAppend(FILEPATH,TimeUtils.getNowTime()+e);
		}
	}

	@Override
	public String toString() {
		return "FileConfigGet{" +
				"url='" + url + '\'' +
				", user='" + user + '\'' +
				", passWord='" + passWord + '\'' +
				", fileName='" + fileName + '\'' +
				", fileRoad='" + fileRoad + '\'' +
				", tableName='" + tableName + '\'' +
				", taigetidName='" + taigetidName + '\'' +
				", longitudeName='" + longitudeName + '\'' +
				", latitudeName='" + latitudeName + '\'' +
				", utctimeName='" + utctimeName + '\'' +
				", eliTime='" + eliTime + '\'' +
				", wkTime='" + wkTime + '\'' +
				", ggRoad='" + ggRoad + '\'' +
				", chartRoad='" + chartRoad + '\'' +
				", newFsName='" + newFsName + '\'' +
				", clearEliTime='" + clearEliTime + '\'' +
				'}';
	}
}
